package service

import (
	"context"
	"github.com/jinzhu/copier"
	"stageRpc/client"

	"github.com/cloudwego/hertz/pkg/app"
	stage "stage/hertz_gen/stage"
	rpcModel "stageRpc/kitex_gen/stage"
)

type GetDeskListService struct {
	RequestContext *app.RequestContext
	Context        context.Context
}

func NewGetDeskListService(Context context.Context, RequestContext *app.RequestContext) *GetDeskListService {
	return &GetDeskListService{RequestContext: RequestContext, Context: Context}
}

func (h *GetDeskListService) Run(req *stage.Param) (resp *[]*stage.Desk, err error) {
	var param = &rpcModel.Param{}
	r, err := client.StageClient.GetDeskList(h.Context, param)
	if err != nil {
		return nil, err
	}
	var tmpList = make([]*stage.Desk, 0)
	if err = copier.Copy(&tmpList, r); err != nil {
		return nil, err
	}
	resp = &tmpList
	return
}
